<template>
	<view class="content">
		<view style="height: 20vh;background-color: #fff;padding-top: 20rpx;">
			<view style="display: flex;justify-content: space-between;width: 90%;margin: auto;">
				<view style="display: flex;flex-direction: column;justify-content: space-between;width: 70%;">
					<view style="font-weight: 700;color: red;font-size: 35rpx;">{{user_info.companyName}}</view>
					<view @click="phone_btn(user_info.headPhone)"
						style="font-weight: 700;color: red;font-size: 35rpx;color: #3c9cff;text-decoration: underline;  ;">
						{{user_info.headName+'-'+user_info.headPhone}}
					</view>
					<view style="display: flex;" v-if="companyNum_off == 2">
						<view style="width: 49%; "><u-button @click="add_btn" type="warning">添加车辆</u-button>
						</view>
						<view style="width: 49%; margin-left: 2%;">
							<u-button open-type="share" type="success">我要分享</u-button>
						</view>
					</view>
					<view style="display: flex;" v-if="companyNum_off == 1">
						<view style="width: 49%; " v-if="companyNum_off == 1"><u-button @click="car_btn"
								type="warning">我要用车</u-button></view>
						<view style="width: 49%; margin-left: 2%;" v-if="companyNum_off == 1">
							<u-button @click="go_car_btn" type="success">成为车队</u-button>
						</view>
					</view>
				</view>
				<view style="display: flex;flex-direction: column;align-items: center;font-weight: 700;width: 25%;">
					<view>加微信</view>
					<view v-if="user_info.personalQrcodeUrl != ''">
						<u-image :show-menu-by-longpress="true" :src="user_info.personalQrcodeUrl" @click="previewImage"
							width="130" height="130" mode="aspectFill"></u-image>
					</view>
					<view v-else style="width: 200rpx;font-size: 25rpx;font-weight: 400;">
						没有微信二维码图片请先在【我的-修改账号信息】上传微信二维码
					</view>
				</view>
			</view>
			<view class="other-btns" style="padding: 20rpx; 20rpx">
				<label class="lt-obtn" :class="{'lt-obtn-sel': findDay == 0}" @click="findDgByDay('0')">轿车</label>

				<label class="lt-obtn" :class="{'lt-obtn-sel': findDay == 1}" @click="findDgByDay('1')">越野车</label>

				<label class="lt-obtn" :class="{'lt-obtn-sel': findDay == 2}" @click="findDgByDay('2')">商务</label>

				<label class="lt-obtn" :class="{'lt-obtn-sel': findDay == 3}" @click="findDgByDay('3')">保姆</label>

				<label class="lt-obtn" :class="{'lt-obtn-sel': findDay == 4}" @click="findDgByDay('4')">中巴</label>

				<label class="lt-obtn" :class="{'lt-obtn-sel': findDay == 5}" @click="findDgByDay('5')">大巴</label>
			</view>

		</view>

		<scroll-view :scroll-top="scrollTop" @scroll="scroll" style="height: 75vh;width: 100%;" scroll-y
			@scrolltolower="tabReachBottom" :refresher-enabled="true" :refresher-threshold="80"
			:refresher-background="'#efefef'" :refresher-triggered="load.triggered" @refresherrefresh="downPullRefres">
			<view class="my-list">
				<view class="no-data" v-if="list_data.length == 0"><u-empty text="没有车辆数据" mode="list"></u-empty></view>
				<template v-else>

					<view v-for="(item, index) in list_data" :key="index">
						<view @click.stop="delite_btn3(item)"
							style="display: flex;width: 100vw;height: 15vh;margin-top: 15rpx;background-color: #fff;">
							<view style="width: 30vw;margin-left: 10rpx;">
								<u-image :previewFullImage='true' :show-loading="true" :src="item.vehicleUrl"
									width="30vw" height="15vh" mode="aspectFill"></u-image>
							</view>
							<view
								style="font-size: 30rpx; margin-left: 20rpx;display: flex; flex-direction: column;    justify-content: space-between;">
								<view style="font-weight: 700;">{{item.vehicleBrand}}
									<text
										style="color: #41a863;margin-left: 10rpx;width: 460rpx;white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">【{{item.seats}}座{{item.vehicleConfig}}】
									</text>
								</view>
								<view
									style="width: 460rpx;white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
									{{item.vehicleExplain?item.vehicleExplain:''}}
								</view>

								<view style="width: 460rpx; display: flex;">

									<view style="margin-left: 10rpx;color: #2979ff;width: 450rpx;"
										v-if="item.periodDate.length>0">

										<view style="display: flex;justify-content: space-between;">

											<view v-if="companyNum_off == 2" @click.stop="go_tuanqi(item)"
												style="width: 220rpx;height: 60rpx;color: #fff;background-color:#3c9cff ;border-radius: 8rpx;text-align: center;font-size: 25rpx;line-height: 60rpx;">
												查看团期

											</view>
											<view @click.stop="go_kongqi(item)"
												style="width: 220rpx;height: 60rpx;color: #fff;background-color:#f9ae3d ;border-radius: 8rpx;text-align: center;font-size: 25rpx;line-height: 60rpx;">
												查看空期

											</view>
										</view>
									</view>
									<view style="margin-left: 10rpx;color: red;width: 450rpx;" v-else>
										长期空期
									</view>
								</view>
								<view style="display: flex;    justify-content: space-between;    ">
									<view v-if="companyNum_off == 2">
										<view @click.stop="periodDate_btn(item)"
											style="width: 120rpx;height: 60rpx;color: #fff;background-color:#5ac725 ;border-radius: 8rpx;text-align: center;font-size: 25rpx;line-height: 60rpx;">
											设置团期
										</view>
									</view>
									<view v-if="companyNum_off == 2" style="margin-left: 10rpx;">
										<view @click.stop="up_btn(item)"
											style="width: 120rpx;height: 60rpx;color: #fff;background-color:#f9ae3d ;border-radius: 8rpx;text-align: center;font-size: 25rpx;line-height: 60rpx;">
											修改
										</view>
									</view>
									<view style="margin-left: 10rpx;" v-if="companyNum_off == 2">
										<view @click.stop="del_btn(item)"
											style="width: 120rpx;height: 60rpx;color: #fff;background-color:#f56c6c ;border-radius: 8rpx;text-align: center;font-size: 25rpx;line-height: 60rpx;">
											删除
										</view>
									</view>

									<view style="margin-left: 10rpx;" v-if="companyNum_off == 2">

										<view @click.stop="delite_btn(item)"
											style="width: 120rpx;height: 60rpx;color: #fff;background-color:#3c9cff ;border-radius: 8rpx;text-align: center;font-size: 25rpx;line-height: 60rpx;">
											单独分享
										</view>
									</view>
									<view style="margin-left: 10rpx;" v-if="companyNum_off != 2">

										<view @click.stop="delite_btn2(item)"
											style="width: 120rpx;height: 60rpx;color: #fff;background-color:#3c9cff ;border-radius: 8rpx;text-align: center;font-size: 25rpx;line-height: 60rpx;">
											详情
										</view>
									</view>

								</view>
							</view>
						</view>


					</view>

					<u-loadmore :status="load.status" :load-text="load.loadText" bgColor="#f2f2f2"></u-loadmore>
				</template>


			</view>
		</scroll-view>


		<!-- 弹窗 -->
		<!-- 添加修改 -->

		<u-popup v-model="add_show" mode="center" border-radius="14" :mask-close-able='false' closeable='true'
			@close="add_clone">
			<view style="width: 600rpx;padding: 0 30rpx;">
				<view style="text-align: center;font-weight: 700;font-size: 35rpx;margin-top: 40rpx;">{{add_title}}
				</view>
				<view style="margin-top: 20rpx;">
					<view>
						<u-input maxlength='10' type='text' placeholder="请输入车辆品牌(最多10个字)" border="surround"
							v-model="add_data.vehicleBrand"></u-input>
					</view>
					<view style="margin-top: 10rpx;display: flex; align-items: center;">
						<u-input disabled='true' @click="seats_btn" type='select' placeholder="请选择车辆座位数"
							border="surround" v-model="add_data.seats ">
						</u-input>
						<view
							style="margin-left: 10rpx;font-weight: 700;background-color: aliceblue;border: 1px solid #d49595;padding: 15rpx 20rpx;">
							座</view>
					</view>
					<view style="margin-top: 10rpx;">
						<u-input @click="vehicleConfig_btn" disabled='true' type='select' placeholder="请选择车辆配置"
							border="surround" v-model="vehicleConfig_text">
						</u-input>
					</view>
					<view style="margin-top: 10rpx;">
						<view style="font-weight: 700;">车辆类型:</view>
						<view class="other-btns" style="padding: 20rpx; 20rpx">
							<label class="lt-obtn"
								:class="{'lt-obtn-sel': vehicleType.indexOf('CAR') != -1?true:false }"
								@click="add_findDgByDay('CAR')">轿车</label>

							<label class="lt-obtn" :class="{'lt-obtn-sel':vehicleType.indexOf('SUV') != -1?true:false }"
								@click="add_findDgByDay('SUV')">越野车</label>

							<label class="lt-obtn"
								:class="{'lt-obtn-sel': vehicleType.indexOf('MPV') != -1?true:false }"
								@click="add_findDgByDay('MPV')">商务</label>

							<label class="lt-obtn"
								:class="{'lt-obtn-sel': vehicleType.indexOf('BMPV') != -1?true:false }"
								@click="add_findDgByDay('BMPV')">保姆</label>

							<label class="lt-obtn"
								:class="{'lt-obtn-sel': vehicleType.indexOf('MINIBUS') != -1?true:false }"
								@click="add_findDgByDay('MINIBUS')">中巴</label>

							<label class="lt-obtn" style="margin-top: 20rpx;"
								:class="{'lt-obtn-sel': vehicleType.indexOf('BIGBUS') != -1?true:false }"
								@click="add_findDgByDay('BIGBUS')">大巴</label>
						</view>
					</view>


					<view style="margin-top: 10rpx;">
						<u-upload ref="qtjzUf" width="200" height="200" max-count="6" :file-list="fileList"
							:action="ufAction" :header="ufHeader" :name="'file'"
							:form-data="{ftype: 'BACK_SET_DATA_IMG', }"></u-upload>
						<!-- <u-upload :multiple='true' :file-list="fileList" @afterRead="add_afterRead"
							@delete="add_deletePic" :previewFullImage="true" name="1" :max-count="5"></u-upload> -->
					</view>
					<view style="margin-top: 10rpx;">
						<u-input border="surround" type="textarea" v-model="add_data.vehicleExplain"
							placeholder="请输入用车详情" :auto-height="true" disabledColor="#ffffff"></u-input>
					</view>



				</view>
				<view style="margin-top: 40rpx;">
					<u-button @click="add_ok_btn" type="primary">提交</u-button>
				</view>
			</view>
		</u-popup>

		<!-- 时间 -->
		<!-- <u-picker mode="time" @confirm='datetime_confirm' @cancel='datetime_cancel' hasInput v-model="datetime_value"
			:show="datetime_show" mode="date"></u-picker> -->
		<!-- 车辆座位 -->
		<u-select class="picker-font-size" @confirm="seats_confirm" @cancel="seats_cancel" v-model="seats_off"
			:list="columns"></u-select>
		<!-- 车辆配置 -->
		<u-select class="picker-font-size" @confirm="getCarConfigurationType_list_confirm"
			@cancel="getCarConfigurationType_list_cancel" v-model="getCarConfigurationType_list_off"
			:list="getCarConfigurationType_list"></u-select>
		<!-- 日历 -->
		<!-- <u-calendar :defaultDate="defaultDate_list" :maxDate="maxDate" :minDate="minDate" :show="periodDate_off"
			mode="multiple"  @close="calendar_close"></u-calendar> -->
		<wu-calendar @confirm="calendar_confirm" :useToday="true" slideSwitchMode="vertical"
			:monthShowCurrentMonth="true" :startDate="minDate" :endDate="maxDate" operationPosition='bottom'
			ref="wucalendar1" :insert="false" mode="multiple" :date="defaultDate_list">
		</wu-calendar>

		<!-- 日历2 -->
		<wu-calendar cancelColor='#fff' :useToday="true" slideSwitchMode="vertical" :monthShowCurrentMonth="true"
			:startDate="minDate" :endDate="maxDate" color='#fc5531' operationPosition='bottom' :disabledChoice='true'
			ref="wucalendar" :insert="false" mode="multiple" :date="defaultDate_list2">

		</wu-calendar>
		<!-- 删除 -->
		<u-modal @confirm='del_confirm'  :show-cancel-button='true' v-model="del_off" confirm-text="删除"
			content='确认删除车辆?'></u-modal>
		<!-- 下单 -->


		<u-popup v-model="car_off" mode="center" border-radius="14" :mask-close-able='false' closeable='true'
			@close="car_close">
			<view style="width: 600rpx;height: 250rpx;padding: 30rpx 30rpx;">
				<view style="text-align: center;font-weight: 700;font-size: 35rpx;">我要用车</view>
				<view style="display: flex;justify-content: space-between;margin-top: 40rpx;">

					<view style="width: 250rpx;">
						<u-button @click="go_adupTravelAdviceFollow" type="warning">旅游行程包车咨询</u-button>
					</view>
					<view style="width: 250rpx;">
						<u-button @click="go_order" type="primary">接送机火车下单</u-button>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {

		data() {
			return {

				// 文件上传地址
				ufAction: this.C.upfileUrl,
				// 文件上传请求头信息
				ufHeader: {
					'token': uni.getStorageSync(this.C.uuid)
				},
				luser: {},
				userId: null,
				user_info: {},
				companyNum_off: 2,
				companyNum: null,
				find_data: {
					stime: '',
					etime: '',
					seats: '',
					page: {
						pageNum: 1,
						pageSize: 20,
					},
					companyNum: '',
					vehicleType: '',
				},
				num_car: null,
				findDay: -1,
				tuanqi_title: '',
				defaultDate_list2: [],
				periodDate_off2: false,
				datetime_show: false,
				datetime_value: null,
				data_no: 0,
				list_off: false,
				list_data: [],
				page_off: 2,
				add_show: false,
				seats_off: false,
				columns: [{
						value: '5',
						label: '5座',
					}, {
						value: '7',
						label: '7座',
					},
					{
						value: '9',
						label: '9座',
					}, {
						value: '12',
						label: '12座',
					}, {
						value: '14',
						label: '14座',
					}, {
						value: '17',
						label: '17座',
					},
					{
						value: '23',
						label: '23座',
					},
					{
						value: '39',
						label: '39座',
					}, {
						value: '49',
						label: '49座',
					}, {
						value: '55',
						label: '55座',
					},
				],
				getCarConfigurationType_list: [],
				getCarConfigurationType_list_off: false,
				defaultDate_list: [],
				defaultDate: null,
				minDate: null,
				maxDate: null,
				periodDate_off: false,
				periodDate_data: {
					id: '',
					periodDate: '',
				},
				fileList: [],
				add_title: '',
				vehicleUrl_list: [],
				vehicleConfig_text: '',
				vehicleType: [],
				add_data: {
					id: '',
					periodDate: '',
					seats: '',
					vehicleBrand: '',
					vehicleExplain: '',
					vehicleConfig: '',
					vehicleUrl: '',
					vehicleType: '',
				},
				car_off: false,
				del_id: null,
				del_off: false,
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				total: 0,
				load: this.U.scopy(this.C.loadmore),

			}
		},
		onReady() {



		},
		onShareAppMessage(res) {
			let that = this
			let luser = uni.getStorageSync('LUSER')


			let userId2 = that.userId

			if (luser) {
				if (luser.userId == that.userId) {
					if (luser.userIdOfCompany) {
						userId2 = that.luser.userIdOfCompany
					} else {
						userId2 = that.luser.userId
					}
				} else {
					userId2 = that.userId
				}
			} else {
				userId2 = that.userId
			}
			return {
				title: that.user_info.companyName + that.num_car + '车辆展示，欢迎客户或同行调用！',
				type: 0,
				path: '/my-man/my_car/my_car?companyNum=' + that.companyNum + '&userId=' + userId2,
				mpPath: '/my-man/my_car/my_car?companyNum=' + that.companyNum + '&userId=' + userId2,

				success: (res) => {
				},

				fail: (res) => {
				},
			}

		},
		onLoad(e) {
			let that = this
			that.luser = uni.getStorageSync('LUSER')
			that.defaultDate = Date.now()
			that.datetime_value = Date.now()
			that.minDate = new Date().toISOString().split('T')[0];
			let today = new Date();
			today.setMonth(today.getMonth() + 1);
			that.maxDate = today.toISOString().split('T')[0];

			if (e.companyNum) {

				that.companyNum_off = 1
				that.userId = e.userId
				that.find_data.companyNum = e.companyNum
				that.companyNum = e.companyNum
				that.$u.api.findMiniProgramInfoNoLogin({
					userId: e.userId,
				}).then(res => {
					that.user_info = res.data
					that.user_info.personalQrcodeUrl = 'https://cba360.com' + that.user_info.personalQrcodeUrl


				})
			} else {
				let luser = uni.getStorageSync('LUSER')
				that.companyNum = luser.companyNum
				that.companyNum_off = 2
				that.userId = luser.userId
				that.find_data.companyNum = that.companyNum
				that.$u.api.findMiniProgramInfo({
					userId: luser.userId,
				}).then(res => {
					that.user_info = res.data
					that.user_info.personalQrcodeUrl = 'https://cba360.com' + that.user_info.personalQrcodeUrl


				})

			}


			that.list_api()

		},
		// 在 App.vue 中设置页面切换监听
		onShow() {

		},
		mounted() {




		},
		methods: {

			scroll: function(e) {

				this.old.scrollTop = e.detail.scrollTop
			},
			goTop: function(e) {
				let that = this
				// 解决view层不同步的问题

				that.scrollTop = that.old.scrollTop

				that.$nextTick(function() {
					that.scrollTop = 0

				});


			}, // 设置-底部上滑加载数据时状态显示
			tabReachBottom() {
				let that = this;

				// 数据已经加载完
				if (that.list_data.length == that.total) {
					// 设置加载状态为：没有更多了
					that.load.status = 'nomore';
				} else {
					// 设置加载状态为：加载中...
					that.load.status = 'loading';
					// 增加一页页码
					that.find_data.page.pageNum++;
					that.list_api(1);
				}
			},
			// 下拉刷新
			downPullRefres() {
				// 重新查询

				this.list_api();
			},

			previewImage() {
				let that = this
				uni.previewImage({
					// 需要预览的图片链接列表
					urls: [],
					// 为当前显示图片的链接/索引值
					current: 'https://cba360.com/' + that.user_info.personalQrcodeUrl,
					// 图片指示器样式	
					indicator: 'default',
					// 是否可循环预览
					loop: false,
					// 长按图片显示操作菜单，如不填默认为保存相册
					// longPressActions:{
					// 	itemList:[this.l('发送给朋友'),this.l]
					// },
					success: res => {
					},
					fail: err => {
					}
				});
			},
			findDgByDay(e) {
				let day = parseInt(e);

				if (this.findDay == day) {
					// 再次点击则取消
					this.findDay = -1;
					this.find_data.vehicleType = ''


					this.list_api()
				} else {
					this.findDay = day;
					if (this.findDay == 0) {
						this.find_data.vehicleType = 'CAR'
					} else if (this.findDay == 1) {
						this.find_data.vehicleType = 'SUV'
					} else if (this.findDay == 2) {
						this.find_data.vehicleType = 'MPV'
					} else if (this.findDay == 3) {
						this.find_data.vehicleType = 'BMPV'
					} else if (this.findDay == 4) {
						this.find_data.vehicleType = 'MINIBUS'
					} else if (this.findDay == 5) {
						this.find_data.vehicleType = 'BIGBUS'
					}


					this.list_api()
				}
			},

			periodDate2_off(e) {
				// let data = false
				// if (e) {

				// 	if (e.split(',').length > 3) {
				// 		data = true
				// 	} else {
				// 		data = false
				// 	}
				// } else {
				// 	data = false
				// }
				// return data
			},

			go_tuanqi(e) {
				this.tuanqi_title = '查看团期'

				if (e) {
					this.defaultDate_list2 = e.periodDate3

				} else {
					this.defaultDate_list2 = []
				}
				this.$refs.wucalendar.open();
				// this.periodDate_off2 = true
			},

			go_kongqi(e) {
				this.tuanqi_title = '查看空期'
				if (e) {
					this.defaultDate_list2 = e.periodDate4
				} else {
					this.defaultDate_list2 = []
				}
				this.$refs.wucalendar.open();
				// this.periodDate_off2 = true
			},
			calendar_confirm2() {
				this.periodDate_off2 = false
			},
			calendar_close2() {
				this.periodDate_off2 = false
			},
			seats_input() {
				this.list_api()
			},
			datetime_cancel() {
				this.datetime_show = false
			},
			datetime_confirm(e) {
				let timestamp = e.value; // 一个时间戳示例
				let date = new Date(timestamp);

				let year = date.getFullYear();
				let month = date.getMonth() + 1; // 月份是从0开始计数的，所以需要加1
				let day = date.getDate();

				let formattedDate = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;
				if (this.data_no == 1) {
					this.find_data.stime = formattedDate
				} else if (this.data_no == 2) {
					this.find_data.etime = formattedDate
				}
				this.list_api()
				this.datetime_show = false
			},
			stime_btn() {
				this.data_no = 1
				this.datetime_show = true
			},
			etime_btn() {
				this.data_no = 2
				this.datetime_show = true
			},
			scrolltolower_list() {
				this.find_data.page.pageNum += 1
				this.page_off += 1
				if (this.find_data.page.pageNum == this.page_off) {
					this.list_api()

				}
			},
			list_api(page) {
				let that = this

				// 存在，则表示刷新
				if (!page) {
					// 开始刷新
					that.load.triggered = true;
					that.find_data.page.pageNum = 1;
				}
				let params = that.find_data
				that.$u.api.findSeatsTeamPeriodList(params).then(res => {

					// 第一页的时候，停止刷新
					if (!page) {
						// 停止刷新
						that.load.triggered = false;
						// 刷新则清空列表
						that.list_data = [];
					}
					if (res.code == 1) {
						if (res.data.total > res.data.list.length) {
							let dataList = res.data.list


							let dates = [];
							let currentDate = new Date();

							for (let i = 0; i < 32; i++) {
								let year = currentDate.getFullYear();
								let month = currentDate.getMonth() + 1; // 月份加 1
								let day = currentDate.getDate();

								let dateStr =
									`${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
								dates.push(dateStr);

								currentDate.setDate(currentDate.getDate() + 1); // 增加一天
							}



							for (let i = 0; i < dataList.length; i++) {
								if (dataList[i].vehicleUrl) {

									dataList[i].vehicleUrl = 'https://cba360.com/' + dataList[i].vehicleUrl.split(
										',')[0]
								} else {
									dataList[i].vehicleUrl = ''
								}


								if (dataList[i].periodDate) {

									let dates2 = dataList[i].periodDate.split(",")
									let formattedDates2 = dates2.map(date => {
										let [year, month, day] = date.split("-"); // 将日期按照短横线切成年、月、日三部分
										return `${month}-${day}`; // 提取月份和日期部分，格式化成 "MM-DD" 形式
									});


									dataList[i].periodDate = dataList[i].periodDate.split(",")
									dataList[i].periodDate2 = formattedDates2.join(',');
									dataList[i].periodDate3 = dataList[i].periodDate
									dataList[i].periodDate4 = dates.filter(element => !dataList[i].periodDate
										.includes(
											element));
								} else {
									dataList[i].periodDate3 = []
									dataList[i].periodDate = []
									dataList[i].periodDate2 = ''
									dataList[i].periodDate4 = dates
								}





							}

							let num_car_list = []
							let max = 0
							let min = 0
							for (let i = 0; i < dataList.length; i++) {
								num_car_list.push(dataList[i].seats)
							}

							max = Math.max(...num_car_list); // 找出数组中的最大值
							min = Math.min(...num_car_list); // 找出数组中的最小值

							if (min > 0 && max > 0) {
								if (min == max) {
									that.num_car = min + '座'
								} else {
									that.num_car = min + '-' + max + '座'
								}

							} else {
								that.num_car = ''
							}



							that.total = res.data.total
							// 追加数据
							if (that.list_data.length < that.total) {
								that.list_data = that.list_data.concat(dataList);
							} else {

							}


							that.load.status = that.list_data.length == that.total ? 'nomore' : 'loadmore';
						} else {
							let dataList = res.data.list
							let dates = [];
							let currentDate = new Date();

							for (let i = 0; i < 32; i++) {
								let year = currentDate.getFullYear();
								let month = currentDate.getMonth() + 1; // 月份加 1
								let day = currentDate.getDate();

								let dateStr =
									`${year}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
								dates.push(dateStr);

								currentDate.setDate(currentDate.getDate() + 1); // 增加一天
							}


							for (let i = 0; i < dataList.length; i++) {
								if (dataList[i].vehicleUrl) {

									dataList[i].vehicleUrl = 'https://cba360.com/' + dataList[i].vehicleUrl.split(
										',')[0]
								} else {
									dataList[i].vehicleUrl = ''
								}


								if (dataList[i].periodDate) {

									let dates2 = dataList[i].periodDate.split(",")
									let formattedDates2 = dates2.map(date => {
										let [year, month, day] = date.split("-"); // 将日期按照短横线切成年、月、日三部分
										return `${month}-${day}`; // 提取月份和日期部分，格式化成 "MM-DD" 形式
									});


									dataList[i].periodDate = dataList[i].periodDate.split(",")
									dataList[i].periodDate2 = formattedDates2.join(',');
									dataList[i].periodDate3 = dataList[i].periodDate
									dataList[i].periodDate4 = dates.filter(element => !dataList[i].periodDate
										.includes(
											element));
								} else {
									dataList[i].periodDate3 = []
									dataList[i].periodDate = []
									dataList[i].periodDate2 = ''
									dataList[i].periodDate4 = dates
								}





							}

							let num_car_list = []
							let max = 0
							let min = 0
							for (let i = 0; i < dataList.length; i++) {
								num_car_list.push(dataList[i].seats)
							}
							max = Math.max(...num_car_list); // 找出数组中的最大值
							min = Math.min(...num_car_list); // 找出数组中的最小值

							if (min > 0 && max > 0) {
								if (min == max) {
									that.num_car = min + '座'
								} else {
									that.num_car = min + '-' + max + '座'
								}

							} else {
								that.num_car = ''
							}

							// 追加数据
							that.list_data = dataList
							that.total = res.data.total
							// 设置加载状态
							that.load.status = that.list_data.length == that.total ? 'nomore' : 'loadmore';
						}

					}
				});



			},
			add_clone() {
				this.add_show = false
			},
			seats_btn() {
				this.seats_off = true
			},
			seats_cancel() {
				this.seats_off = false
			},
			seats_confirm(e) {
				let that = this

				that.add_data.seats = e[0].value
				that.getCarConfigurationType_list = []
				let lusernum = uni.getStorageSync('LUSER')
				that.$u.api.getCarConfigurationType({
					stationListId: '',
					addWay: '',
					seats: e[0].value,
					companyNum: lusernum.companyNum?lusernum.companyNum:'',
					orderType:'1',
				}).then(res => {
					let data = res.data
					let data_list = []
					for (let i = 0; i < data.length; i++) {
						let obg = {
							id: '',
							text: '',
							val: '',
						}
						obg.id = data[i].id
						obg.label = data[i].val + '(' + data[i].other + ')'
						obg.value = data[i].val
						data_list.push(obg)

					}
					that.getCarConfigurationType_list = data_list
				})
				that.seats_off = false
			},
			vehicleConfig_btn() {
				if (this.add_data.seats == '') {
					return uni.showToast({
						title: "请先选择车辆座位数",
						icon: "none",
						duration: 1000
					})
				}
				this.getCarConfigurationType_list_off = true
			},
			getCarConfigurationType_list_cancel() {
				this.getCarConfigurationType_list_off = false
			},
			getCarConfigurationType_list_confirm(e) {
				this.vehicleConfig_text = e[0].label
				this.add_data.vehicleConfig = e[0].value
				this.getCarConfigurationType_list_off = false
			},
			periodDate_btn(e) {
				if (e.periodDate) {
					this.defaultDate_list = e.periodDate
				} else {
					this.defaultDate_list = []
				}
				this.periodDate_data.id = e.id
				this.periodDate_data.periodDate = ''
				this.$refs.wucalendar1.open();
				// this.periodDate_off = true
			},
			calendar_close() {
				this.periodDate_off = false
			},
			calendar_confirm(e) {
				let that = this
				that.periodDate_data.periodDate = e.multiple.join(',')
				that.$u.api.adupTeamPeriod(that.periodDate_data).then(res => {
					if (res.code == 1) {
						that.list_api()
						that.periodDate_off = false
						return uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
					} else {
						return uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
					}
				})
			},
			phone_btn(e) {
				uni.makePhoneCall({
					phoneNumber: e,
				});
			},
			async add_afterRead(event) {
				let that = this
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file);
				let fileListLen = that.fileList.length;
				lists.map((item) => {
					that.fileList.push({
						...item,
						status: 'uploading',
						message: '上传中',
					});
				});
				for (let i = 0; i < lists.length; i++) {
					const result = await uploadFilePromise(lists[i].url);
					let item = that.fileList[fileListLen];
					that.fileList.splice(fileListLen, 1, {
						...item,
						status: 'success',
						message: '',
						url: result,
					});
					fileListLen++;
				}
			},
			uploadFilePromise(url) {
				let that = this
				return new Promise((resolve, reject) => {

					let a = uni.uploadFile({
						url: 'https://cba360.com/kcbServiceApi/common/uploadFiles',
						header: {
							'token': uni.getStorageSync('token')
						},
						formData: {
							ftype: 'BACK_SET_DATA_IMG',
							file: url
						},
						filePath: url,
						name: 'file',
						success: (res) => {
							setTimeout(() => {
								resolve(res.data);
								let jsonObject = JSON.parse(res);
								that.vehicleUrl_list.push(jsonObject.data.file.url)

							}, 500);
						},
						fail: (res) => {
						}
					});
				});
			},
			add_deletePic(event) {
				this.fileList.splice(event.index, 1);
				this.vehicleUrl_list.splice(event.index, 1);
			},
			add_findDgByDay(e) {
				if (this.vehicleType.length > 0) {
					let data = 0
					let indxe = null
					for (let i = 0; i < this.vehicleType.length; i++) {

						if (e == this.vehicleType[i]) {
							data = 1
							indxe = i
						}
					}

					if (data == 1) {
						this.vehicleType.splice(indxe, 1);
					} else {
						this.vehicleType.push(e)
					}
				} else {
					this.vehicleType.push(e)
				}


			},
			add_btn() {
				this.add_title = '添加车辆'
				this.add_data.id = ''
				this.add_data.periodDate = ''
				this.add_data.seats = ''
				this.add_data.vehicleBrand = ''
				this.add_data.vehicleExplain = ''
				this.add_data.vehicleConfig = ''
				this.add_data.vehicleUrl = ''
				this.add_data.vehicleType = ''

				this.vehicleType = []
				this.vehicleConfig_text = ''
				this.defaultDate_list = []
				this.vehicleUrl_list = []
				this.fileList = []
				this.$refs['qtjzUf'].clear();
				this.add_show = true
			},
			up_btn(e) {
				let that = this
				that.add_title = '修改车辆'
				that.$u.api.getSeatsTeamPeriodById({
					id: e.id
				}).then(res => {
					if (res.code == 1) {
						that.fileList = []
						that.vehicleUrl_list = []
						that.getCarConfigurationType_list = []
						let lusernum = uni.getStorageSync('LUSER')
						that.$u.api.getCarConfigurationType({
							stationListId: '',
							addWay: '',
							seats: res.data.seats,
							companyNum: lusernum.companyNum?lusernum.companyNum:'',
						}).then(res2 => {
							let data = res2.data
							let data_list = []

							for (let i = 0; i < data.length; i++) {
								let obg = {
									id: '',
									text: '',
									val: '',
								}
								obg.id = data[i].id
								obg.label = data[i].val + '(' + data[i].other + ')'
								obg.value = data[i].val
								data_list.push(obg)

							}

							that.getCarConfigurationType_list = data_list

							that.add_data.id = res.data.id
							// add_data.periodDate = res.data.data.periodDate
							that.add_data.seats = String(res.data.seats)
							that.add_data.vehicleBrand = res.data.vehicleBrand
							that.add_data.vehicleExplain = res.data.vehicleExplain

							that.add_data.vehicleConfig = res.data.vehicleConfig
							that.add_data.vehicleUrl = res.data.vehicleUrl

							that.add_data.vehicleType = res.data.vehicleType


							that.vehicleType = res.data.vehicleType ? res.data.vehicleType.split(
								',') : ''
							for (let i = 0; i < data_list.length; i++) {

								if (res.data.vehicleConfig == data_list[i].value) {
									that.vehicleConfig_text = data_list[i].label

								}
							}

							if (res.data.vehicleUrl) {
								that.fileList = []
								that.$refs['qtjzUf'].clear();
								let url_data = res.data.vehicleUrl.split(',')
								url_data.forEach(it => {
									that.fileList.push({
										url: 'https://cba360.com' + it
									});
								});
							}




							that.add_show = true
						})
					} else {
						return uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
					}
				})
			},

			add_ok_btn() {
				let that = this
				that.add_data.vehicleType = that.vehicleType ? that.vehicleType.join(',') : ''

				let uflist = that.$refs.qtjzUf.lists;
				if (uflist.length == 0) {

					return uni.showToast({
						title: '至少需要上传一其他记账张凭证图片',
						icon: "none",
						duration: 1000
					})
				} else {
					let fids = [];

					uflist.forEach(it => {
						if (it.url && it.url.indexOf('_img') != -1) { // 本地图片
							let is = that.fileList.find(fit => it.url.indexOf(fit.url) != -1);
							let url = is.url.split('.com')[1]
							fids.push(url);
						} else { // 新传图片
							if (it.response && it.response.data) fids.push(it.response.data.file.url);
						}
					});
					if (fids.length == 0) {
						fg = U.qinfo('上传图片' + uflist.length + '张，成功' + fids.length + '张');
					} else {
						that.add_data.vehicleUrl = fids.join(',');
					}



				}

				that.$u.api.adupSeatsTeamPeriod(that.add_data).then(res => {
					if (res.code == 1) {
						that.$refs['qtjzUf'].clear();
						that.list_api()
						that.add_show = false
						return uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
					} else {
						return uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
					}
				})
			},
			go_car_btn() {
				let that = this
				uni.navigateToMiniProgram({
					appId: 'wx7c0c100ebfaf705a',
					path: 'pages/tabbar/my/become_a_team/become_a_team?userId=' + that.userId,
					// extraData: {
					//    'miniType': '0'
					// },
					success(res) {
						// 打开成功
					}
				})
			},
			car_btn() {
				this.car_off = true
			},
			car_close() {
				this.car_off = false
			},
			go_car_btn2() {
				this.car_off = false
				uni.clearStorageSync();
				uni.reLaunch({
					url: '/pages/common/index/index?userId=' + userId.value + '&num=1',
				});
			},
			go_adupTravelAdviceFollow() {



				let that = this
				that.car_off = false
				uni.navigateToMiniProgram({
					appId: 'wx7c0c100ebfaf705a',
					path: 'pages/common/index/index?userId=' + that.userId + '&num=1',

					success(res) {

					}
				})
			},
			go_order() {
				let that = this
				that.car_off = false
				uni.navigateToMiniProgram({
					appId: 'wx7c0c100ebfaf705a',
					path: 'pages/common/index/index?userId=' + that.userId + '&num=2',

					success(res) {

					}
				})


			},
			del_btn(e) {

				this.del_id = e.id
				this.del_off = true
			},
			del_confirm() {
				let that = this
				that.$u.api.delSeatsTeamPeriod({
					id: that.del_id
				}).then(res => {
					if (res.code == 1) {
						that.list_api()
						that.del_off = false
						return uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
					} else {
						return uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
					}
				})
			},

			del_cancel() {
				that.del_off = false
			},
			delite_btn(e) {
				let that = this
				uni.navigateTo({
					url: '/my-man/my_car/delite?id=' + e.id + '&userId=' + that.userId,
				});
			},
			delite_btn2(e) {
				let that = this
				uni.navigateTo({
					url: '/my-man/my_car/delite?id=' + e.id + '&userId=' + that.userId + '&companyNum=' +
						that.companyNum,
				});
			},
			delite_btn3(e) {
					let that = this
				if (that.companyNum_off == 2) {
					that.delite_btn(e)
				} else {
					that.delite_btn2(e)
				}
			},


		},





	}
</script>
<style lang="scss">
	.content_img {
		width: 320px;
		margin: auto;
		margin-top: 300rpx;
	}

	.car_css {}

	.other-btns {
		display: inline-block;
	}

	.other-btns .lt-obtn {
		display: inline-block;
		border: 2rpx solid #00C3CE;
		color: #00C3CE;
		border-radius: 10rpx;
		padding: 4rpx 10rpx;
		margin-right: 20rpx;
	}

	.other-btns .lt-obtn-sel {
		background: #00C3CE !important;
		color: #FFFFFF !important;
	}

	.lt-r-btn {
		display: inline-block;
		border: 2rpx solid #00C3CE;
		color: #00C3CE;
		border-radius: 10rpx;
		height: 40rpx;
		line-height: 36rpx;
		padding: 0 6rpx;
	}
</style>